angular.directive('ngl:draggable', function(compileElement) {
    this.descend(true);
    return function(linkElement) {
        $(linkElement).draggable({
            connectToSortable: "#playlist",
            helper: "clone",
            revert: "invalid"
        });
    }
});

angular.widget('ngl:secstring', function(compileElement) {
    return function(linkElement) {
        var sec = Math.floor((this.t.length % 60000)/1000);
		linkElement.text(sec < 10 ? "0" + sec : sec);
    }
});

angular.widget('ngl:minstring', function(compileElement) {
    return function(linkElement) {
		var min = Math.floor(this.t.length/60000);
		linkElement.text(min < 10 ? "0" + min : min);
    }
});

angular.directive('ngl:like', function(expr, compileElem) {
    return function(linkElement) {
        this.$watch(expr, function(val) {
            linkElement.attr('data-id', val);
        });
    };
});

angular.directive('ngl:dislike', function(expr, compileElem) {
    return function(linkElement) {
        this.$watch(expr, function(val) {
            linkElement.attr('data-id', val);
        });
    };
});